/*
 * jxSwing Project (2014)
 * 
 * by Denilson Edinaldo Pinto
 * 
 * LGPL
 * Copyright (C) 2014
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.jxSwing.component.table.cellRenderer;

import java.awt.Component;

import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

import org.jxSwing.component.comboBox.TrueFalseComboBox;
import org.jxSwing.i18n.I18N;

/**
 * @author Denilson Edinaldo Pinto
 * @porject jxSwing
 * @package org.jxSwing.component.table.cellRenderer
 * @date 12/09/2014 - 18:44:51
 */
public class TrueFalseRenderer extends TrueFalseComboBox implements TableCellRenderer {
	
	private static final long serialVersionUID = -2165835995621885882L;
	
	/**
	 * 
	 */
	public TrueFalseRenderer() {
	
		super();
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int)
	 */
	@Override
	public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
	
		//
		if(isSelected) {
			
			setForeground(table.getSelectionForeground());
			setBackground(table.getSelectionBackground());
			
		}else {
			
			setForeground(table.getForeground());
			setBackground(table.getBackground());
		}
		
		setSelectedItem(value != null ? (boolean)value ? I18N.component().truee() : I18N.component().falsee() : null);
		
		return this;
	}
}
